﻿using System;
using System.Configuration;
using System.Net;
using System.Windows.Forms;
using CookComputing.XmlRpc;
using sklik_api;

namespace test_sklik_api
{
    public partial class Form1 : Form
    {

        public static string SklikServer = ConfigurationManager.AppSettings["SklikServer"];
        public static string SklikUser = ConfigurationManager.AppSettings["SklikUser"];
        public static string SklikPass = ConfigurationManager.AppSettings["SklikPass"];
        private static ISklikAPI SklikApi;

        public Form1()
        {
            InitializeComponent();
        }


        

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {

                SklikApi = XmlRpcProxyGen.Create<ISklikAPI>();
                SklikApi.Url = SklikServer;
                SklikApi.Timeout = 50000;
                SklikApi.KeepAlive = false;
                SklikApi.ProtocolVersion = HttpVersion.Version10;



                LoginIn login = SklikApi.login(SklikUser, SklikPass);
                if (login.status != 200)
                    throw new Exception("login returns: " + login.status + " " + login.statusMessage);
                    
            }
            catch
            {
            }
        }
    }
}
